package com.example.hasee.zhcd.Adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.hasee.zhcd.R;
import com.example.hasee.zhcd.Util.GlobalParameter;

import java.util.ArrayList;
import java.util.HashMap;


/**
 * Created by hasee on 2017/9/13.
 */

public class CgsDetailAdapter extends BaseAdapter {
    private HashMap<String, String> map = (HashMap<String, String>) GlobalParameter.get("loginmap");
    private ArrayList<HashMap<String, String>> list;
    private LayoutInflater itemInflater;
    private Context context;
    private Holder holder;

    public CgsDetailAdapter(Context context, ArrayList<HashMap<String, String>> list) {
        this.context = context;
        this.list = list;
        this.itemInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        if (convertView == null) {
            holder = new Holder();
            convertView = itemInflater.inflate(R.layout.cgs_detail_list_item, null);
            holder.fshipname = (TextView) convertView.findViewById(R.id.fshipname);
            holder.fhc = (TextView) convertView.findViewById(R.id.fhc);
            holder.fjd = (TextView) convertView.findViewById(R.id.fjd);
            holder.fkbsj = (TextView) convertView.findViewById(R.id.fkbsj);
            holder.fberth = (TextView) convertView.findViewById(R.id.fberth);
            holder.fwgsj = (TextView) convertView.findViewById(R.id.fwgsj);
            holder.flgsj = (TextView) convertView.findViewById(R.id.flgsj);
            holder.flx = (TextView) convertView.findViewById(R.id.flx);
            holder.fzx = (TextView) convertView.findViewById(R.id.fzx);
            holder.fhm = (TextView) convertView.findViewById(R.id.fhm);
            holder.fsl = (TextView) convertView.findViewById(R.id.fsl);
            holder.ffl = (TextView) convertView.findViewById(R.id.ffl);
            holder.fdlf = (TextView) convertView.findViewById(R.id.fdlf);
            convertView.setTag(holder);
        } else {
            holder = (Holder) convertView.getTag();
        }
        holder.fshipname.setText((String) list.get(position).get("fshipname"));
        holder.fhc.setText((String) list.get(position).get("fhc"));
        holder.fjd.setText((String) list.get(position).get("fjd"));
        holder.fkbsj.setText((String) list.get(position).get("fkbsj"));
        holder.fberth.setText((String) list.get(position).get("fberth"));
        holder.fwgsj.setText((String) list.get(position).get("fwgsj"));
        holder.flgsj.setText((String) list.get(position).get("flgsj"));
        holder.flx.setText((String) list.get(position).get("flx"));
        holder.fzx.setText((String) list.get(position).get("fzx"));
        holder.fhm.setText((String) list.get(position).get("fhm"));
        holder.fsl.setText((String) list.get(position).get("fsl"));
        holder.ffl.setText((String) list.get(position).get("ffl"));
        holder.fdlf.setText((String) list.get(position).get("fdlf"));
        return convertView;
    }

    class Holder {
        private TextView fshipname;
        private TextView fhc;
        private TextView fjd;
        private TextView fkbsj;
        private TextView fberth;
        private TextView fwgsj;
        private TextView flgsj;
        private TextView flx;
        private TextView fzx;
        private TextView fhm;
        private TextView fsl;
        private TextView ffl;
        private TextView fdlf;
    }
}
